﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using YhmOA.Common;
using System.Data;
using YhmOA.Model;
using YhmOA.IDAL;

namespace YhmOA.ManagerOA.Menu
{
    public partial class TopMenuInfo : FormPage<ManagerOA_Menu_TopMenu>
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadData();
            }
        }

        private bool SaveManagerOA_User_User()
        {
            Local = base.CreateInstance();
            if (this._ID == 0)
            {
                return this.Dal.Add(Local);
            }
            else
            {
                return this.Dal.Update(Local, this._ID);
            }
        }

        protected void btnSaveAndClose_Click(object sender, EventArgs e)
        {
            if (SaveManagerOA_User_User())
            {
                MessageBox("成功");
                ExecClientScript("try{window.parent.Search();}catch(ex){}");
            }
            else
            {
                MessageBox("失败");
            }
        }

        protected void btnSaveAndAdd_Click(object sender, EventArgs e)
        {
            if (SaveManagerOA_User_User())
            {
                MessageBox("成功");
                ExecClientScript("try{window.parent.Search();}catch(ex){}");
            }
            else
            {
                MessageBox("失败");
            }
        }
    }
}